import React, { ReactNode } from 'react';
import {
  SmileOutlined,
  SettingOutlined,
  FileTextOutlined,
} from '@ant-design/icons';

export interface KRoute {
  path: string;
  access?: string;
  title?: string;
  menu?: {
    name?: string;
    icon?: ReactNode;
  };
  component?: string;
  routes?: this[];
}

/**
 * path 路由
 * access 使用权限
 * title 网页标题
 * menu.name 菜单名称，如果为空则使用网页标题
 * menu.icon 侧栏图标
 * menu.hide 是否隐藏侧栏
 * menu.active 指定激活侧栏
 * component 组件
 * routes 子级路由
 */
export default [
  {
    path: '/welcome',
    title: '欢迎页',
    menu: {
      icon: <SmileOutlined />,
    },
    component: '@/pages/welcome',
  },

  {
    path: '/system',
    title: '系统',
    menu: {
      icon: <SettingOutlined />,
    },
    routes: [
      {
        path: '/system/settings',
        access: 'SysSetting@write',
        title: '站点配置',
        component: '@/pages/system/settings',
      },
      {
        path: '/system/users',
        access: 'Manager@write',
        title: '管理员',
        component: '@/pages/system/users',
      },
      {
        path: '/system/users/new',
        access: 'Manager@write',
        title: '创建管理',
        menu: {
          hide: true,
          active: 'system/users',
        },
        component: '@/pages/system/users/new',
      },
      {
        path: '/system/users/:id',
        access: 'Manager@read',
        title: '管理员信息',
        menu: {
          hide: true,
          active: 'system/users',
        },
        component: '@/pages/system/users/detail',
      },
      {
        path: '/system/roles',
        access: 'ManagerRole@write',
        title: '角色',
        component: '@/pages/system/roles',
      },
      {
        path: '/system/roles/:id',
        title: '角色信息',
        menu: {
          hide: true,
          active: 'system/roles',
        },
        component: '@/pages/system/roles/detail',
      },
      {
        path: '/system/action_logs',
        access: 'ManagerLog@read',
        title: '操作日志',
        component: '@/pages/system/action_logs',
      },
    ],
  },

  {
    path: '/article',
    access: 'Article',
    title: '资讯中心',
    menu: {
      icon: <FileTextOutlined />,
    },
    routes: [
      {
        path: 'category',
        title: '分类管理',
        component: '@/pages/article/category',
      },

      {
        path: 'index',
        title: '文章管理',
        component: '@/pages/article/index',
      },
      {
        path: 'edit',
        title: '文章管理',
        menu: {
          hide: true,
          active: 'article/index',
        },
        component: '@/pages/article/index/form',
      },
    ],
  },

  {
    path: '/',
    redirect: '/welcome',
  },
] as KRoute[];
